//
//  MyCell.m
//  UI08_homework(通讯录)
//
//  Created by Hanlingyu on 16/7/25.
//  Copyright © 2016年 ltq. All rights reserved.
//

#import "MyCell.h"
#define kWidth self.frame.size.width
#define kHeight self.frame.size.height

@implementation MyCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    
    self.backGroundView = [[UIView alloc] init];
    _backGroundView.backgroundColor = [UIColor clearColor];
#warning 加在self上切换编辑状态时候不会自适应, 加在contentView上才能自适应
    [self.contentView addSubview:_backGroundView];
    
    self.headImageView = [[UIImageView alloc] init];
    _headImageView.backgroundColor = [UIColor clearColor];
//    _headImageView.layer.cornerRadius = 100 / 2;
    _headImageView.layer.masksToBounds = YES;
    [self.backGroundView addSubview:_headImageView];
    
    self.nameLabel = [[UILabel alloc] init];
    _nameLabel.backgroundColor = [UIColor clearColor];
    _nameLabel.textAlignment = 1;
    [self.backGroundView addSubview:_nameLabel];
    
    self.phoneNumberLabel = [[UILabel alloc] init];
    _phoneNumberLabel.backgroundColor = [UIColor clearColor];
    _phoneNumberLabel.textAlignment = 1;
    [self.backGroundView addSubview:_phoneNumberLabel];
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.backGroundView.frame = CGRectMake(0, 0, kWidth, kHeight);
    
    self.headImageView.frame = CGRectMake(0, 0, kWidth / 4, kWidth / 4);
    self.nameLabel.frame = CGRectMake(kWidth / 4, 0, kWidth / 4 * 3, kHeight / 2);
    self.phoneNumberLabel.frame = CGRectMake(kWidth / 4, kHeight / 2, kWidth / 4 * 3, kHeight / 2);

    
}



- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
